package gpx;


import java.util.*;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 * Class responsible for sending email with comments of users
 * @author Josef Vermach jr.
 *
 */
public class Sender {
	/**
	 * Receiver of message
	 */
	protected String address = "vermy@seznam.cz";
	/**
	 * Subject of message
	 */
	protected String subject = "BTC - message";
	/**
	 * Copy to
	 */
	protected String copy = "";
	
	protected String message = "message";
	
	protected Session session;
	
	protected MimeMessage mimeMess;
	
	public void doSend() {
		Properties p = new Properties();
		
		p.put("smtp.klfree.net", "smtp.klfree.net");
		session = Session.getDefaultInstance(p,null);
		session.setDebug(false);
		try {
			mimeMess = new MimeMessage(session);
			
			mimeMess.setFrom(new InternetAddress("vermy@seznam.cz"));
			InternetAddress internetAddress = new InternetAddress(address);
			mimeMess.addRecipient(Message.RecipientType.TO, internetAddress);
			InternetAddress copyAddress = new InternetAddress(copy);
			mimeMess.addRecipient(Message.RecipientType.CC, copyAddress);
			mimeMess.setSubject(subject, "ISO-8859-2");
			mimeMess.setText(message,"ISO-8859-2");
		} catch (MessagingException e) {
			while ((e = (MessagingException) e.getNextException()) != null) {
				e.printStackTrace();
			}
			
		}
	}
	
	
	
	

}
